package com.woniu.springmvc.handler;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @program: JavaEE-EFD
 * @description: 用户控制层
 * @author: fengjd
 * @create: 2022-07-28 19:32
 **/
public class UserController implements Controller {
    @Override
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        ModelAndView model = new ModelAndView();
        String userName = httpServletRequest.getParameter("userName");
        String password = httpServletRequest.getParameter("password");

        boolean b = "admin".equals(userName) && "admin".equals(password);
        if (b) {
            model.setViewName("success");
        } else {
            model.setViewName("fail");
        }

        return model;
    }
}
